package com.kingsystem.kingteachermarks_backend.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kingsystem.kingteachermarks_backend.KingUtil.JwtOper;
import com.kingsystem.kingteachermarks_backend.entity.CalcDuration;
import com.kingsystem.kingteachermarks_backend.mapper.CalcDurationMapper;
import io.jsonwebtoken.Jwt;
import org.apache.coyote.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author leiyue_yao
 * @since 2025-05-22
 */
@Controller
@RequestMapping("/calcDuration")
@CrossOrigin
public class CalcDurationController extends HttpServlet {
    @Autowired
    private CalcDurationMapper cdm;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response){
        String aa = request.getHeader("aa");
    }

    @RequestMapping("/getAllCalcDuration")
    @ResponseBody
    public List<CalcDuration> getAllCalcDuration(HttpServletRequest request){

        String aa = request.getHeader("aa");
        System.out.println(aa);
        QueryWrapper<CalcDuration> qw = new QueryWrapper<>();
        qw.orderByDesc("calc_year");
        List<CalcDuration> li = cdm.selectList(qw);
        return li;
    }
}
